package net.tavion.angelboot.fegin.logger;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class FeignAccessLogger implements AccessLogger {

    @Resource
    private ObjectMapper objectMapper;

    public FeignAccessLogger(ObjectMapper objectMapper) {
        this.objectMapper = objectMapper;
    }

    @Override
    public <T> void request(RequestInfo<T> requestInfo) {
        try {
            log.info(this.objectMapper.writeValueAsString(requestInfo));
        } catch (Exception var3) {
            log.error("", var3);
        }

    }

    @Override
    public <T> void response(ResponseInfo<T> responseInfo) {
        try {
            log.info(this.objectMapper.writeValueAsString(responseInfo));
        } catch (Exception var3) {
            log.error("", var3);
        }

    }
}
